package hichecker.university;

import hichecker.controller.MainController;
import hichecker.ui.components.icon_factory.IconFactory.IconType;
import hichecker.ui.custom_views.passing.PassingCondition.ConditionType;
import hichecker.ui.general_views.container_panel.content.ContentPanel;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * A super class for all classes of the university package
 */
public abstract class UniversityPart implements Comparable<UniversityPart> {

	/**
	 * @return the unique id
	 */
	public abstract UUID getID();

	/**
	 * @return name of the object
	 */
	public abstract String getName();

	public abstract List<UniversityPart> getSubParts();

	public abstract UniversityPart[] getPossibleSubPart();

	public abstract List<ConditionType> getPossibleConditions();

	public abstract UUID addSubPart(int type);

	public abstract void removeSubPart(UUID id);

	public abstract ContentPanel getRepresentation(boolean showConfig, MainController controller);

	public abstract IconType getIcon();

	public abstract IconType getAddIcon();

	@Override
	public int compareTo(UniversityPart that) {
		// Hierachy of the classes
		List<Class<?>> order = new ArrayList<Class<?>>();
		order.add(Course.class);
		order.add(PVL.class);
		order.add(PTL.class);
		order.add(Series.class);
		order.add(Task.class);

		// Order of both object in die hierachy
		int thisOrder = order.indexOf(this.getClass());
		int thatOrder = order.indexOf(that.getClass());

		// If both objects are equal sort by name
		if (thisOrder == thatOrder)
			return this.getName().compareTo(that.getName());
		// Sort by hierachy level
		else if (thisOrder < thatOrder)
			return -1;
		else
			return 1;
	}
}
